/**
 * 微信用户关注服务号后，点击菜单，进行用户授权，后台完成用户注册操作（执行create方法）
 * Created by icyhy on 2017/5/23.
 */
"use strict";
var builder = require("../response/rest.result.builder");
var userModel = require("../models/user");
module.exports = {

  login : function (req, res, next) {
    var userEntity = userModel.login();
    console.log(userEntity);
    return builder.buildSuccessResultInfo(res, userEntity);
  },
  register:function(req, res, next){
    var id = req.params.id || '';
    console.log( req.params.id);
    userModel.findOne({
      _id: id
    })
      .exec(function(err, record) {
        if (err) return next(err);
        if (!record) return next(new Error('not  found'));
        return builder.buildSuccessResultInfoWithData(res, record);
      });
  }
}
